package com.diors.commons.thread;

import java.lang.Thread.UncaughtExceptionHandler;

import com.diors.commons.log.DiorsLogger;

/**
 * 线程未捕获到异常而终止时调用处理类
 * @author	darren.ouyang
 * @data	2013-9-4
 */
public class ThreadUncaughtExceptionHandler implements UncaughtExceptionHandler
{

	private static final DiorsLogger log = DiorsLogger.getLogger(ThreadUncaughtExceptionHandler.class);
	
	@Override
	public void uncaughtException(Thread t, Throwable e) 
	{
		log.error("严重错误 - 线程: " + t.getName() + " 终止异常 " + e, e);
		
		if (e instanceof OutOfMemoryError)
			log.error("内存不足! 需要更多的内存!");
	}

}
